import http from '@/utils/http';

/**
 * 获取区域树
 * @param params
 * @returns {*|Promise<any>}
 */
export const categoryTreeSelectData = (params?: any) => {
  Date
  return http.get('bus/category/treeSelectData?' + Math.floor(Math.random() *1000), {params});
}

/**
 * 获取区域树型表格数据
 * @param params
 * @returns {*|Promise<any>}
 */
export const getCategoryTreeTableData = (params: any = {}) => {
  return http.get('bus/category/treeTableData', {params});
}

/**
 * 删除区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const removeCategory = (params: any) => {
  return http.delete('bus/category/remove', {params});
}

/**
 * 保存修改区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const updateCategory = (params: any) => {
  return http.put('bus/category/edit', params);
}

/**
 * 保存新增区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const addCategory = (params: any) => {
  return http.post('bus/category/add', params);
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getBigCategory = (params?: any) => {
  return http.get('bus/category/getBigCategory',{params});
}

/**
 * 通过id获取区域信息
 * @param params
 * @returns {*|Promise<any>}
 */
export const getById = (params: any) => {
  return http.get('bus/category/' + params.id);
}

/**
 * 验证区域名称是否唯一
 * @param params
 * @returns {*|Promise<any>}
 */
export const checkCategoryNameUnique = (params: any) => {
  params.loading = false;
  return http.post('bus/category/checkNameUnique', params);
}

/**
 * 查询最小的调查分类
 * @param params
 */
export const getMinCategory =(params?: any)=>{
  return http.get('/bus/category/getMinCategory');
}

